import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		hasLogin: false,
		venue: false,
		shopId: '1',
		qqjx: true,
		city: "场馆",
		imgHost: 'XXXXXXXXX',
		ossHost: '',
		openId: '',
		userInfo: '',
		albumStatus: '',
		token: '',
		venueName: '',
		venuephone: '',
		venueId: '',
		tabUrl: [],
		formwork: 'index',
		color: '#DD5040',
	},
	mutations: {
		setTheme(state, data) {
			state.theme = data;
		},
		setTabUrl(state, data) {
			state.tabUrl = data;
		},
		setColor(state, data) {
			state.color = data;
		},
		setRenovationInfo(state, data) {
			state.renovationInfo = data;
		},
		login(state, data) {
			state.token = data;
			uni.setStorage({
				key: 'token',
				data: data
			});
		},
		setqqjx(state, data) {
			state.qqjx = data;
		},
		setShopid(state, data) {
			state.shopId = data;
		},
		setAlbumStatus(state, data) {
			state.albumStatus = data;
		},
		setFormwork(state, data) {
			state.formwork = data;
		},
		setImgHost(state, data) {
			state.imgHost = data;
		},
		setVenuephone(state, data) {
			state.venuephone = data;
		},
		setVenueName(state, data) {
			state.venueName = data;
			uni.setStorage({
				key: 'venueName',
				data: data
			});
		},
		setOssHost(state, data) {
			state.ossHost = data;
			uni.setStorage({
				key: 'ossHost',
				data: data
			});
		},
		setOpenId(state, data) {
			state.openId = data;
			uni.setStorage({
				key: 'openId',
				data: data
			});
		},
		setVenueId(state, data) {
			state.venueId = data;
			uni.setStorage({
				key: 'venueId',
				data: data
			});
		},
		logout(state, data) {
			state.hasLogin = false;
			state.venue = false;
			state.token = '';
			state.userInfo = '';
			uni.removeStorageSync('userInfo');
			uni.removeStorageSync('token');
		},
		// 保存用户信息
		saveUserInfo(state, data) {
			state.hasLogin = true;
			state.userInfo = data;
			uni.setStorage({
				key: 'userInfo',
				data: data
			});
		},
		setHasLogin(state, data) {
			state.hasLogin = data;
		},
		setVenue(state, data) {
			state.venue = data;
		}
	}
})

export default store
